<?php

namespace Sffi\ElementPlus\entity;

use Sffi\ElementPlus\base\EntityToArray;

class Option
{
    use EntityToArray;

    protected string $value;
    protected string $label;
    protected bool $disable;
    /**
     * @var Option[] $children
     */
    protected array $children;

    public function __construct($key, $value, $disable=false, $children=[])
    {
        $this->label = $key;
        $this->value = $value;
        $this->disable = $disable;
        $this->children = $children;
    }

    public function addChildren(Option $children)
    {
        $this->children[] = $children;
    }

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }

    /**
     * @param string $value
     */
    public function setValue(string $value): self
    {
        $this->value = $value;
        return $this;
    }

    /**
     * @return string
     */
    public function getKey(): string
    {
        return $this->label;
    }

    /**
     * @param string $key
     */
    public function setKey(string $key): self
    {
        $this->label = $key;
        return $this;
    }

    /**
     * @return bool
     */
    public function isDisable(): bool
    {
        return $this->disable;
    }

    /**
     * @param bool $disable
     */
    public function setDisable(bool $disable): self
    {
        $this->disable = $disable;
        return $this;
    }

    /**
     * @return Option[]
     */
    public function getChildren(): array
    {
        return $this->children;
    }

    /**
     * @param array $children
     */
    public function setChildren(array $children): self
    {
        $this->children = $children;
        return $this;
    }

}